Dynomotion

Group: DynoMotion Message: 7008 From: funncarsmi Date: 3/17/2013
Subject: c code ....
I have a lot of learning to do with this C code stuff. I can read and understand what is happening when others write the code, but I struggle to get it in the right configuration so it will compile even when I copy and paste most of it.
While it is easy to configure the M3 and M4 codes using 2 stop bits, I need to configure 3 bits to configure M5 to stop the spindle. As long as I must do that, I might as well learn to write the code for M3 and M4.

I would like to both insure the the machine is not damaged if someone switches the spindle directly from CW to CCW without stopping first ...and pausing (wait loop) for a few hundred miliseconds after clearing the bit to stop the spindle so the spindle actually can stop before I release the brake with the setbit18=1 command. (I saw that command but I can't find it again)

M3 example that will not compile:

#include "KMotionDef.h"
//M3 Turns Spindle ON in Clockwise direction
main()
{
Setbit17=1; //turn spindle CCW LED off
ClearBit18; //stop spindle if spinning
Setbit18=1; //turn stop spindle LED off
ClearBit16; //Turn spindle on CW
}



Is there a good site that describes C code for dummies?
I've never found writing computer code difficult, but I don't have much in the way of directions. Is this C or C++ that I should be reading about?
Gregg
Group: DynoMotion Message: 7010 From: himykabibble Date: 3/17/2013
Subject: Re: c code ....
What you've written is not C code, those are KFlop console commands. You need:

#include "KMotionDef.h"

main()
{
SetBit(17); //turn spindle CCW LED off
ClearBit(18); //stop spindle if spinning
SetBit(18); //turn stop spindle LED off
ClearBit(16); //Turn spindle on CW
}

Though the second and third lines make no sense - you're clearing, then immediately setting, I/O 18.

Regards,
Ray L.

--- In DynoMotion@yahoogroups.com, "funncarsmi" <funncars@...> wrote:
>
> I have a lot of learning to do with this C code stuff. I can read and understand what is happening when others write the code, but I struggle to get it in the right configuration so it will compile even when I copy and paste most of it.
> While it is easy to configure the M3 and M4 codes using 2 stop bits, I need to configure 3 bits to configure M5 to stop the spindle. As long as I must do that, I might as well learn to write the code for M3 and M4.
>
> I would like to both insure the the machine is not damaged if someone switches the spindle directly from CW to CCW without stopping first ...and pausing (wait loop) for a few hundred miliseconds after clearing the bit to stop the spindle so the spindle actually can stop before I release the brake with the setbit18=1 command. (I saw that command but I can't find it again)
>
> M3 example that will not compile:
>
> #include "KMotionDef.h"
> //M3 Turns Spindle ON in Clockwise direction
> main()
> {
> Setbit17=1; //turn spindle CCW LED off
> ClearBit18; //stop spindle if spinning
> Setbit18=1; //turn stop spindle LED off
> ClearBit16; //Turn spindle on CW
> }
>
>
>
> Is there a good site that describes C code for dummies?
> I've never found writing computer code difficult, but I don't have much in the way of directions. Is this C or C++ that I should be reading about?
> Gregg
>
Group: DynoMotion Message: 7011 From: funncarsmi Date: 3/17/2013
Subject: Re: c code ....
Yes, in the second line I am clearing I/O 18 (which stops the spindle. and I really need to wait 1/2 second for the brake to actually stop the spindle), the the third lines I must set I/O 18 to release the brake so the spindle can be directed to spin.

Thank you for the help. But your code also would not compile without en error. "undefined symbol "setbit"

-Gregg

--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy1964@...> wrote:
>
> What you've written is not C code, those are KFlop console commands. You need:
>
> #include "KMotionDef.h"
>
> main()
> {
> SetBit(17); //turn spindle CCW LED off
> ClearBit(18); //stop spindle if spinning
> SetBit(18); //turn stop spindle LED off
> ClearBit(16); //Turn spindle on CW
> }
>
> Though the second and third lines make no sense - you're clearing, then immediately setting, I/O 18.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "funncarsmi" <funncars@> wrote:
> >
> > I have a lot of learning to do with this C code stuff. I can read and understand what is happening when others write the code, but I struggle to get it in the right configuration so it will compile even when I copy and paste most of it.
> > While it is easy to configure the M3 and M4 codes using 2 stop bits, I need to configure 3 bits to configure M5 to stop the spindle. As long as I must do that, I might as well learn to write the code for M3 and M4.
> >
> > I would like to both insure the the machine is not damaged if someone switches the spindle directly from CW to CCW without stopping first ...and pausing (wait loop) for a few hundred miliseconds after clearing the bit to stop the spindle so the spindle actually can stop before I release the brake with the setbit18=1 command. (I saw that command but I can't find it again)
> >
> > M3 example that will not compile:
> >
> > #include "KMotionDef.h"
> > //M3 Turns Spindle ON in Clockwise direction
> > main()
> > {
> > Setbit17=1; //turn spindle CCW LED off
> > ClearBit18; //stop spindle if spinning
> > Setbit18=1; //turn stop spindle LED off
> > ClearBit16; //Turn spindle on CW
> > }
> >
> >
> >
> > Is there a good site that describes C code for dummies?
> > I've never found writing computer code difficult, but I don't have much in the way of directions. Is this C or C++ that I should be reading about?
> > Gregg
> >
>
Group: DynoMotion Message: 7012 From: himykabibble Date: 3/17/2013
Subject: Re: c code ....
Did you type "setbit" or "SetBit"? Capitalization is significant. Type it *exactly* as I did, and it does compile.

If you need a 1/2 second delay, use "Delay_sec(0.5);".

Regards,
Ray L.

--- In DynoMotion@yahoogroups.com, "funncarsmi" <funncars@...> wrote:
>
> Yes, in the second line I am clearing I/O 18 (which stops the spindle. and I really need to wait 1/2 second for the brake to actually stop the spindle), the the third lines I must set I/O 18 to release the brake so the spindle can be directed to spin.
>
> Thank you for the help. But your code also would not compile without en error. "undefined symbol "setbit"
>
> -Gregg
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy1964@> wrote:
> >
> > What you've written is not C code, those are KFlop console commands. You need:
> >
> > #include "KMotionDef.h"
> >
> > main()
> > {
> > SetBit(17); //turn spindle CCW LED off
> > ClearBit(18); //stop spindle if spinning
> > SetBit(18); //turn stop spindle LED off
> > ClearBit(16); //Turn spindle on CW
> > }
> >
> > Though the second and third lines make no sense - you're clearing, then immediately setting, I/O 18.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "funncarsmi" <funncars@> wrote:
> > >
> > > I have a lot of learning to do with this C code stuff. I can read and understand what is happening when others write the code, but I struggle to get it in the right configuration so it will compile even when I copy and paste most of it.
> > > While it is easy to configure the M3 and M4 codes using 2 stop bits, I need to configure 3 bits to configure M5 to stop the spindle. As long as I must do that, I might as well learn to write the code for M3 and M4.
> > >
> > > I would like to both insure the the machine is not damaged if someone switches the spindle directly from CW to CCW without stopping first ...and pausing (wait loop) for a few hundred miliseconds after clearing the bit to stop the spindle so the spindle actually can stop before I release the brake with the setbit18=1 command. (I saw that command but I can't find it again)
> > >
> > > M3 example that will not compile:
> > >
> > > #include "KMotionDef.h"
> > > //M3 Turns Spindle ON in Clockwise direction
> > > main()
> > > {
> > > Setbit17=1; //turn spindle CCW LED off
> > > ClearBit18; //stop spindle if spinning
> > > Setbit18=1; //turn stop spindle LED off
> > > ClearBit16; //Turn spindle on CW
> > > }
> > >
> > >
> > >
> > > Is there a good site that describes C code for dummies?
> > > I've never found writing computer code difficult, but I don't have much in the way of directions. Is this C or C++ that I should be reading about?
> > > Gregg
> > >
> >
>
Group: DynoMotion Message: 7013 From: Tom Kerekes Date: 3/17/2013
Subject: Re: c code ....
Hi Gregg,

Here is a post with links to other links:

http://tech.groups.yahoo.com/group/DynoMotion/message/5018

Regards
TK

Group: DynoMotion Message: 7023 From: funncarsmi Date: 3/18/2013
Subject: Re: c code ....
Ray,
I corrected my capitalization error and double checked each individual letter against your text and finding no differences, it still wouldn't compile.
Then I copied and pasted your text and it compiles! I must be overlooking something small.

I used your code as the base version and now have all my spindle commands written (with the time delays). My spindle commands are all compiled, linked in KMotionCNC and ready for testing today.
Thank you!!!

Gregg

--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy1964@...> wrote:
>
> Did you type "setbit" or "SetBit"? Capitalization is significant. Type it *exactly* as I did, and it does compile.
>
> If you need a 1/2 second delay, use "Delay_sec(0.5);".
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "funncarsmi" <funncars@> wrote:
> >
> > Yes, in the second line I am clearing I/O 18 (which stops the spindle. and I really need to wait 1/2 second for the brake to actually stop the spindle), the the third lines I must set I/O 18 to release the brake so the spindle can be directed to spin.
> >
> > Thank you for the help. But your code also would not compile without en error. "undefined symbol "setbit"
> >
> > -Gregg
> >
> > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy1964@> wrote:
> > >
> > > What you've written is not C code, those are KFlop console commands. You need:
> > >
> > > #include "KMotionDef.h"
> > >
> > > main()
> > > {
> > > SetBit(17); //turn spindle CCW LED off
> > > ClearBit(18); //stop spindle if spinning
> > > SetBit(18); //turn stop spindle LED off
> > > ClearBit(16); //Turn spindle on CW
> > > }
> > >
> > > Though the second and third lines make no sense - you're clearing, then immediately setting, I/O 18.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, "funncarsmi" <funncars@> wrote:
> > > >
> > > > I have a lot of learning to do with this C code stuff. I can read and understand what is happening when others write the code, but I struggle to get it in the right configuration so it will compile even when I copy and paste most of it.
> > > > While it is easy to configure the M3 and M4 codes using 2 stop bits, I need to configure 3 bits to configure M5 to stop the spindle. As long as I must do that, I might as well learn to write the code for M3 and M4.
> > > >
> > > > I would like to both insure the the machine is not damaged if someone switches the spindle directly from CW to CCW without stopping first ...and pausing (wait loop) for a few hundred miliseconds after clearing the bit to stop the spindle so the spindle actually can stop before I release the brake with the setbit18=1 command. (I saw that command but I can't find it again)
> > > >
> > > > M3 example that will not compile:
> > > >
> > > > #include "KMotionDef.h"
> > > > //M3 Turns Spindle ON in Clockwise direction
> > > > main()
> > > > {
> > > > Setbit17=1; //turn spindle CCW LED off
> > > > ClearBit18; //stop spindle if spinning
> > > > Setbit18=1; //turn stop spindle LED off
> > > > ClearBit16; //Turn spindle on CW
> > > > }
> > > >
> > > >
> > > >
> > > > Is there a good site that describes C code for dummies?
> > > > I've never found writing computer code difficult, but I don't have much in the way of directions. Is this C or C++ that I should be reading about?
> > > > Gregg
> > > >
> > >
> >
>